<?php

if (!defined('BASEPATH')) exit('No direct script access allowed');

class Post extends Manage_Controller
{
	public $postright;

	public function __construct()
	{
		parent::__construct();

		$this->load->library('postright');
		$this->postright = $this->postright->get_right($this->broker);
        $this->data['postright'] = $this->postright;
	}

	/**
	 * 发布出售
	 */
	public function addsale()
	{
		if ($_POST)
		{
			//权限判断
			$this->has_right();

            echo '发布';
			exit;
		}

		$this->load->view('manage/post_addsale', $this->data);
	}

	/**
	 * 发布出租
	 */
	public function addhire()
	{
		if ($_POST)
		{
			//权限判断
			$this->has_right();

			echo '发布';
			exit;
		}

		$this->load->view('manage/post_addhire', $this->data);
	}

	/**
	 * 是否允许发布权限判断
	 */
	private function has_right()
	{
		$postright = $this->postright;

		if ($postright['posttype'] == 'fixed' && $postright['postnum'] == 0)
		{
			show_msg("亲，总发布量 {$postright['postnum']} 条 已经用完了哦");
			//return FALSE;
		}
		elseif ($postright['posttype'] == 'month' && $this->user['monthhirenum'] + $this->user['monthsalenum'] >= $postright['postnum'])
		{
			show_msg("亲，本月发布量 {$postright['postnum']} 条 已经用完了哦");
			//return FALSE;
		}
		elseif ($postright['posttype'] == 'week' && $this->user['weekhirenum'] + $this->user['weeksalenum'] >= $postright['postnum'])
		{
			show_msg("亲，本周发布量 {$postright['postnum']} 条 已经用完了哦");
			//return FALSE;
		}
		elseif ($postright['posttype'] == 'day' && $this->user['todayhirenum'] + $this->user['todaysalenum'] >= $postright['postnum'])
		{
			show_msg("亲，本日发布量 {$postright['postnum']} 条 已经用完了哦");
			//return FALSE;
		}

		return TRUE;
	}
}

/* End of file post.php */
/* Location: ./application/controllers/manage/post.php */
